﻿using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel;
using Basic.FormRemoteModel.FormDataSource.Model;
using Basic.FormRemoteModel.FormDataSourceItem.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;

namespace Basic.FormGatewaryModular.Api
{
    [ApiRouteName("/form/source/{name}")]
    internal class FormSourceApi : ApiController
    {
        private readonly IFormSourceService _Service;

        public FormSourceApi ( IFormSourceService service )
        {
            this._Service = service;
        }

        public DataSourceItem[] Gets ( [EnumValidate("form.table.type.error", typeof(FormTableType))] FormTableType tableType )
        {
            return this._Service.Ges(tableType);
        }
        public SourceItem[] GetItems ( [NullValidate("form.source.key.null")][LenValidate("form.source.key.len", 1, 50)] string sourKey )
        {
            return this._Service.GetItems(sourKey);
        }
    }
}
